import { createApp } from 'vue'
import { createPinia } from 'pinia'

import App from './App.vue'
import router from './router'
const app = createApp(App)
app.use(createPinia())
app.use(router)

/* 自动化注册src下的components公共组件 */
const modules = import.meta.glob('./components/*.vue')

for (const path in modules) {
  modules[path]().then(module => {
    const componentName = path
      .split('/')
      .pop()
      .replace(/\.\w+$/, '')
    app.component(componentName, module.default)
  })
}

app.mount('#app')

console.log('以VITE开头的环境变量', import.meta.env.VITE_BASE_API)
console.log('以VUE开头的环境变量', import.meta.env.VUE_BASE_API)
